package hjslm.Controller.Background;

import hjslm.Bean.WeixinBean;
import hjslm.Common.Impl.CommonFunImpl;
import hjslm.Service.IWeixinService;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import framework.base.controller.BaseController;


@Controller
@RequestMapping("b_weixin")
public class WeixinController extends BaseController{

	/**
	 * 微信控制层
	 */
	private static final long serialVersionUID = 1L;
	
	

	@Autowired
	IWeixinService weixinService;
	
	@Override
	public void setLogger() {
	}
	
	@RequestMapping("/index")
	public ModelAndView index(){
		ModelAndView modelAndView = new ModelAndView("background/weixin/index");
		List<WeixinBean> list = weixinService.selectList(null);
		modelAndView.addObject("list", list);
		return modelAndView;
	}
	
	@RequestMapping("/edit")
	public ModelAndView edit(WeixinBean bean){
		ModelAndView modelAndView = new ModelAndView("background/weixin/edit");
		bean = weixinService.selectOne(bean);
		modelAndView.addObject("bean", bean);
		return modelAndView;
	}
	
	@RequestMapping("/update")
	public void update(WeixinBean bean,HttpServletResponse response){
		bean.setInserttime(CommonFunImpl.currentTime(1));
		int retVal =weixinService.update(bean);
		try {
			PrintWriter out = response.getWriter();
			out.print(retVal);
			out.close();
		} catch (IOException e) {
			e.printStackTrace();// 打印异常
		}
	}

}
